package com.briup.web.controller;

import com.briup.result.Result;
import com.briup.util.UploadOSSUtils;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.UUID;

@RestController
@Api(tags = "文件上传")
@Slf4j
@RequestMapping("/file")
public class UploadController {
    @Autowired
    private UploadOSSUtils uploadUtils;

    @PostMapping("/upload")
    public Result uploadByQiNiuOSS(@RequestPart("file") MultipartFile file){
        String url = uploadUtils.uploadOss(file, UUID.randomUUID().toString() + file.getOriginalFilename());
        return Result.success(url);
    }
}
